package net.seninp.fdata.data;

import java.util.ArrayList;
import java.util.Iterator;

public class Measurements implements Iterable<Measurement> {

  private ArrayList<Measurement> data;

  public Measurements() {
    this.data = new ArrayList<Measurement>();
  }

  public void add(Measurement m) {
    this.data.add(m);
  }

  public Integer size() {
    return this.data.size();
  }

  public Double getMaxLatd() {
    double max = Integer.MIN_VALUE;
    for (Measurement m : this.data) {
      if (m.getLatd() > max) {
        max = m.getLatd();
      }
    }
    return max;
  }

  public Double getMinLatd() {
    double min = Integer.MAX_VALUE;
    for (Measurement m : this.data) {
      if (m.getLatd() < min) {
        min = m.getLatd();
      }
    }
    return min;
  }

  public Double getMaxLond() {
    double max = Integer.MIN_VALUE;
    for (Measurement m : this.data) {
      if (m.getLond() > max) {
        max = m.getLond();
      }
    }
    return max;
  }

  public Double getMinLond() {
    double min = Integer.MAX_VALUE;
    for (Measurement m : this.data) {
      if (m.getLond() < min) {
        min = m.getLond();
      }
    }
    return min;
  }

  @Override
  public Iterator<Measurement> iterator() {
    return this.data.iterator();
  }

}
